package newConvert;

import java.awt.*;
import javax.swing.*;

public class XPanel extends JPanel {
	
	private static final long serialVersionUID = 1L;
	GridBagLayout layout;
	GridBagConstraints cons;

	public XPanel() {
		super();
		layout = new GridBagLayout();
		cons = new GridBagConstraints();
		setLayout(layout);
	}
	
	protected void setConstraints(int x, int y, int width, int height, int anchor, Insets insets) {
		setConstraints(x,y,width,height,anchor);
		cons.insets = insets;
	}

	protected void setConstraints(int x, int y, int width, int height, int anchor) {
		cons.gridx = x;
		cons.gridy = y;
		cons.gridwidth = width;
		cons.gridheight = height;
		cons.anchor = anchor;
		cons.weightx = 10;
		cons.weighty = 0;
		cons.insets = new Insets(0,0,0,0);
	}
	
	protected void addComponent(Component obj, int x, int y, int width, int height, int anchor, Insets insets) {
		if (insets != null) setConstraints(x,y,width,height,anchor,insets);
		else setConstraints(x,y,width,height,anchor);
		layout.setConstraints(obj,cons);
		add(obj);
	}
	
	protected void addComponent(Component obj, int x, int y, int width, int height, int anchor) {
		addComponent(obj, x, y, width, height, anchor, null);
	}
}
